package com.qfedu.edu.seckill.manager;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;

@Component
public class RabbitMQManager {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 向队列中发送消息
     * @param queueName
     * @param message
     */
    public void sendToWork(String queueName,String message) throws UnsupportedEncodingException {
        Message msg = new Message(message.getBytes("UTF-8"), new MessageProperties());
        rabbitTemplate.send(queueName,msg);
    }



}
